package com.qzxy.premiumhotelsystem.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qzxy.premiumhotelsystem.common.constant.RedisKeyConstant;
import com.qzxy.premiumhotelsystem.domain.entity.VipTypes;
import com.qzxy.premiumhotelsystem.service.VipTypesService;
import com.qzxy.premiumhotelsystem.mapper.VipTypesMapper;
import com.qzxy.premiumhotelsystem.utils.RedisUtil;
import org.springframework.stereotype.Service;

import jakarta.annotation.Resource;
import java.util.List;

/**
* @author 14912
* @description 针对表【vip_types】的数据库操作Service实现
* @createDate 2024-09-13 22:48:27
*/
@Service
public class VipTypesServiceImpl extends ServiceImpl<VipTypesMapper, VipTypes>
    implements VipTypesService{

    @Resource
    private VipTypesMapper vipTypesMapper;

    @Resource
    private RedisUtil redisUtil;



    @Override
    public void armoryVipTypesMes() {
        List<VipTypes> vipTypes = vipTypesMapper.selectList(null);
        for (VipTypes vipType : vipTypes) {
            String cacheKey = RedisKeyConstant.VIP_TYPE_KEY + vipType.getVipTypeId();
            redisUtil.setCacheObject(cacheKey,vipType);
        }

    }

    /**
     * 根据vipid获取vip名字
     * @param vipTypeId
     * @return
     */
    @Override
    public String getByVipTypeIdString(String vipTypeId) {
        return vipTypesMapper.getByVipTypeIdString(vipTypeId);
    }
}




